from selenium.webdriver.common.by import By

from base.base import BasePage,BaseHandle
#定义对象层
class HomePage(BasePage):
    def __init__(self):
        super().__init__()
        #用户名显示元素
        self.username = By.CLASS_NAME,"#navbar-avatar"
        # 写随笔按钮
        self.WritingEssays_btn = By.ID,"new_post_icon"

    #定位用户的头像ID
    def find_userimgID(self):
        return self.get_element(self.userimgID)

    #定位写随笔按钮
    def find_WritingEssays_btn(self):
        return self.get_element(self.WritingEssays_btn)


#定义操作层
class HomeHandle(BaseHandle):
    def __init__(self):
        self.home_page = HomePage()

    #获取用户名信息
    def get_userimgID(self):
        return self.home_page.find_userimgID().ID
    #点击写随笔按钮
    def click_WritingEssays_btn(self):
        self.home_page.find_WritingEssays_btn().click()
#定义业务层
class HomeProxy:
    def __init__(self):
        self.home_handle = HomeHandle()

    #获取用户头像ID信息
    def get_userimgID(self):
        return self.home_handle.get_userimgID()
    #跳转到写随笔页面
    def go_WritingEssays_page(self):
        self.home_handle.click_WritingEssays_btn()